package api;

public class RobotAPIWrapperTester implements RobotAPIWrapper
{
  private double speed;

  public RobotAPIWrapperTester()
  {
    speed = 100;
  }

  public boolean isReady()
  {
    return true;
  }

  public void forward()
  {
    System.out.println("Moving forward at " + speed + ".");
  }

  public void backward()
  {
    System.out.println("Moving backward at " + speed + ".");
  }

  public void stop()
  {
    System.out.println("Stopped.");
  }

  public void left()
  {
    System.out.println("Turning left at " + speed + ".");
  }

  public void right()
  {
    System.out.println("Turning right at " + speed + ".");
  }

  private void boundSpeed()
  {
    if(speed > 100)
      speed = 100;
    if(speed < 1)
      speed = 1;
  }

  public void setSpeed(int perdec)
  {
    speed = perdec * 10;
    boundSpeed();
    System.out.println("Setting speed to " + speed + ".");
  }

  public void speedUp(int perdec)
  {
    speed = speed * (perdec + 10) / 10.0;
    boundSpeed();
    System.out.println("Speeding up by " + perdec + " to " + speed + ".");
  }

  public void slowDown(int perdec)
  {
    speed = speed * (10 - perdec) / 10.0;
    boundSpeed();
    System.out.println("Slowing down by " + perdec + " to " + speed + ".");
  }
}
